package org.accp.daner.service.impl;

import entity.address;
import entity.reported_info;
import org.accp.daner.dto.Dto;
import org.accp.daner.dto.PageBean;
import org.accp.daner.mapper.ReportedInfoMapper;
import org.accp.daner.service.ReportedInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ReportedInfoServiceImpl implements ReportedInfoService {

    @Resource
    private ReportedInfoMapper reportedInfoMapper;

    @Override
    public PageBean queryAllByLimit(Dto dto) {
        System.out.println(dto);
        if(dto.getIndex()==null) dto.setIndex(1);
        if(dto.getEnd()==null) dto.setEnd(5);
       int rowCount = this.reportedInfoMapper.count(dto);
       PageBean p=new PageBean(dto.getIndex(),dto.getEnd(),rowCount);
       dto.setIndex(p.getStartIndex());
       dto.setEnd(p.getEndIndex());
        System.out.println(dto);
       List<reported_info> list=this.reportedInfoMapper.queryAllByLimit(dto);
        p.setData(list);
        return p;
    }

    @Override
    public Integer count(Dto dto) {
        return this.reportedInfoMapper.count(dto);
    }

    @Override
    public Integer ByidCount(String handle) {
        return this.reportedInfoMapper.ByidCount(handle);
    }


    @Override
    public void insert(reported_info re) {
        this.reportedInfoMapper.insert(re);
    }

    @Override
    public void update(reported_info re) {
        this.reportedInfoMapper.update(re);
    }

    @Override
    public void deleteById(Integer id) {
        this.reportedInfoMapper.deleteById(id);
    }

    @Override
    public List<address> alladdress(String fid) {
        return this.reportedInfoMapper.queryAllAddress(fid);
    }

    @Override
    public reported_info queryByid(String id) {
        return this.reportedInfoMapper.queryByid(id);
    }

    @Override
    public address queryByidAddress(String id) {
        return this.reportedInfoMapper.queryByidAddress(id);
    }
}
